<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>更新学生信息</title>
		<script type="text/javascript" src="js/jquery-1.8.0.min.js">
</script>
		<style mce_bogus="1">
table {
	border-collapse: collapse;
}

td {
	border: 1px solid #f00;
}
</style>
		<script type="text/javascript">
function turnback() {
	window.location.href = "student.do";
}
function updatestudent() {
	var user = $("#user").val();
	var pwd = $("#pwd").val();
	var id=$("#studid").val();
	if (user == null || user == "" || pwd == null || pwd == "") {
		alert("请埴写姓名和密码！");
	} else {
		$.ajax( {
			type : "POST",
			url : "student.do?method=update",
			dataType : "json",
			data : {
				"id":id,
				"user" : user,
				"psw" : pwd
			},
			success : function(data) {
				if (data.state == "success") {
					alert("修改成功！");
					window.location.href="student.do";
				} else {
					alert("修改失败！");
				}
			},error:function(){
				alert("修改失败！");
			}
		});
	}
}
</script>
	</head>
	<body>
		<form method="post" action="student.do?method=save">
		<input type="hidden" value="${student.id}" id="studid"/>
			<p align="center" style="color: red">
				更新学生信息
			</p>
			<table align="center">
				<tr>
					<td>
						姓名
					</td>
					<td>
						<input id="user" name="user" type="text" value="${student.user}"/>
					</td>
				</tr>
				<tr>
					<td>
						密码
					</td>
					<td>
						<input id="pwd" name="psw" type="text" value="${student.psw}"/>
					</td>
				</tr>
				<tr>
					<td colSpan="2" align="center">
						<input type="button" value="确定" onclick="updatestudent();" />
						<input type="button" onclick="turnback()" value="取消" />
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
